#include <hal/rtc.h>
#include <clock.h>
#include <sys/sysdef.h>

__DEF_SYSCALL1(time_t, time, time_t*, out) {
    rtc_time_t t = read_rtc_time();
    time_t sec = rtc_to_unix(&t);

    if (out) {
        *out = sec;
    }

    return sec;
}
